Skip to content

fix(studio): a sealed crop frame turns with its layer - #8310

Merged
miguel-heygen merged 3 commits into
mainfrom
fix/sealed-crop-frame-turn
Nov 20, 2026
Merged

miguel-heygen merged 3 commits into
mainfrom
fix/sealed-crop-frame-turn

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

In a sealed preview (Studio cannot script the frame), the crop frame of a turned layer now turns with the layer, before any press and after a scrub. Before, it was drawn axis-aligned around the layer until the first press, and after a press it kept the press-time angle when the playhead moved to a frame where GSAP turns the layer differently. An unsealed preview already drew it turned.

The sealed preview is off by default until the sealed-by-default change (#7846) lands, so nothing changes for anyone before then.

Why

A sealed selection is a stand-in: an element in Studio's page with no transform of its own. The crop frame read the turn and scale from the selected element, so for a stand-in it fell back to the axis-aligned box. #8279 gave it the turn and scale from the press (gesture-start's planar), held until the selection changed. So the frame was wrong before a press, and stale after a scrub (the first non-blocking note on #8279).

How

One owner for a stand-in's turn: the frame's watched geometry of the selection, which Studio already keeps for the overlay and which follows the playhead.

Test plan

DomEditCropHandles.sealed.test.ts:

  • "draws a sealed turned card's crop frame turned before any press": a stand-in whose frame geometry reports 30°.
  • "redraws a sealed crop frame at the turn the card has after a scrub, once a press measured it": a press at 30°, then the frame reports 50°.
  • The quarter-turn crop test now passes the oriented overlay rect the overlay hands it.

fails without the fix:

  • with domEditOverlayCrop.ts, DomEditCropHandles.tsx, previewGestureStartRead.ts and previewElements.ts as on main, "draws a sealed turned card's crop frame turned before any press" fails ('' vs rotate(30deg)) and "redraws a sealed crop frame at the turn the card has after a scrub, once a press measured it" fails (rotate(29.99…deg) vs rotate(50deg)).

Run on Linux at this head: the crop handle, overlay crop, gesture-start read and preview element tests pass three runs in a row (69); Studio's hooks, components/editor, webmcp and player tests (6674) pass; Studio vite build and tsc no errors; format and lint clean; fallow audit passes.

Bench

Edit-accuracy bench, every crop case (120 per run: fromto, hold, idle, keys, late, none, scale, size, spin, tween; r0 and r30; root and nested; 50% and 100% zoom). "Crop frame" is the dashed crop outline tracked against the layer through the press and drag. Compared at main and at this change:

preview crop frame off crop frame, worst drop off reload off undo / redo off
sealed, main 46 93.2 px 0 0 15 / 4
sealed, this change 0 0.2 px 0 0 15 / 4
unsealed, main 0 0.2 px 0 0 0 / 0
unsealed, this change 0 0.2 px 0 0 0 / 0

45 of the 46 sealed misses on main are on turned layers (r30, or spin, which GSAP turns), 21 to 93 px off. The other is 1.7 px on an unturned fromto layer, within 0.2 px at this change. The sealed undo and redo misses are the same on both sides; this change does not touch them.

Before

Sealed preview on main, a layer GSAP turns to 40° at the playhead, selected for crop, before any press: the dashed crop frame and its pill are axis-aligned.

before: the crop frame is axis-aligned around the turned layer

After

The same layer at this change: the crop frame and its pill turn with the layer.

after: the crop frame turns with the layer

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 78 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-px-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 790fe5ce. I found no blocker.

  • The rotation's source. standInCropFrame takes the angle and box from overlayRect, which is the oriented groupAwareRect from measurePreviewOverlay, built from the frame's corners. Scale is the overlay edge length divided by the press-measured layout, so non-uniform scale holds, and a flip reads as 180° with positive edges, matching the unsealed atan2 path.
  • Scrubbing and selection. useDomEditOverlayRects re-measures on the frame loop, so the angle follows a scrub. Nothing stores an angle, and state is rebuilt per element, so no previous selection's angle leaks. The PR adds no new listeners.
  • Unsealed path unchanged. previewStandIn is falsy there, so it still reads readPlanarTransform and offsetWidth.
  • Drawn and hit areas agree. The outline and edge handles are children of the same rotated data-dom-edit-crop-frame.
  • Trust boundary. It narrows: Studio stops reading planar from the frame, and no new message is added. The body's fails-without line names two tests that fail on main's code.

Non-blocking:

  • measuredStartOf prefers the held state.start.layout over a newer gestureStartLayout, so a size tweened after the press leaves the scale stale. That's the same as main.
  • Before any press, a scaled layer falls back to the edit scale, so crop insets are mis-scaled until the first press. The body says so.
  • CropPresetBar stays unrotated. That's pre-existing.

CI: every check finished (58 passed, 20 skipped). Edit accuracy is 271 against a base of 271.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 2b0294b Nov 20, 2026
78 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-crop-frame-turn branch November 20, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants